a2b30ecfa4c12cb28adc61ff3013b09fc998a40c,server/sonar-server/src/main/java/org/sonar/server/metric/ws/UpdateAction.java,UpdateAction,checkMetricInDbAndTemplate,#DbSession#MetricDto#MetricDto#,168
Before Change
}
private void checkMetricInDbAndTemplate(DbSession dbSession, @Nullable MetricDto metricInDb, MetricDto template) {
if (!isMetricFoundInDb(metricInDb) || isMetricDisabled(metricInDb) || !isMetricCustom(metricInDb)) {
throw new BadRequestException(String.format("No active custom metric has been found for id '%d'.", template.getId()));
}
checkNoOtherMetricWithTargetKey(dbSession, metricInDb, template);
if (haveMetricTypeChanged(metricInDb, template)) {
List<CustomMeasureDto> customMeasures = dbClient.customMeasureDao().selectByMetricId(dbSession, metricInDb.getId());
if (haveAssociatedCustomMeasures(customMeasures)) {
throw new BadRequestException(String.format("You're trying to change the type '%s' while there are associated custom measures.",
metricInDb.getValueType()));
}
}
}
After Change
checkNoOtherMetricWithTargetKey(dbSession, metricInDb, template);
if (haveMetricTypeChanged(metricInDb, template)) {
List<CustomMeasureDto> customMeasures = dbClient.customMeasureDao().selectByMetricId(dbSession, metricInDb.getId());
checkRequest(!haveAssociatedCustomMeasures(customMeasures), "You're trying to change the type '%s' while there are associated custom measures.", metricInDb.getValueType());
}
}